package com.example.userboot.controller;

import com.example.userboot.pojo.User;
import com.example.userboot.remote.OrderFegin;
import com.example.userboot.remote.PointFegin;
import com.example.userboot.service.UserService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Authther: mrwu
 * @date:2021/6/7-06
 * @Description:com.example.userboot.controller
 */
@RestController
public class UserController {
    @Autowired
    UserService userService;
    @Autowired
    OrderFegin orderFegin;

    @Autowired
    PointFegin pointFegin;


    @GlobalTransactional(rollbackFor = Exception.class)
//    @Transactional
    @PostMapping("/user")
    public String create_user(@RequestBody User user){
        userService.saveOrUpdate(user);
        pointFegin.createpoint();
        //        int a=1/0;
        orderFegin.createOrder();

        return "sucess";
    }
}
